package com.machine.action.component;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.machine.service.user.ComponentServiceDao;
import com.opensymphony.xwork2.ActionSupport;

@Component("addModel")
@Scope(value = "prototype")
public class addModel extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private int id;

	private ComponentServiceDao componentServiceDao;

	public ComponentServiceDao getComponentServiceDao() {
		return componentServiceDao;
	}

	@Resource(name = "componentService")
	public void setComponentServiceDao(ComponentServiceDao componentServiceDao) {
		this.componentServiceDao = componentServiceDao;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	private String path;

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	@Override
	public String execute() throws Exception {
		//System.out.println("add id :　" + id);
		path = path.replaceAll("[\\\\]","/");
		path = path.replaceAll("/Machine/", "");
        componentServiceDao.addModel(id, path);
		return SUCCESS;
	}

}
